package com.prs.crm.dao.doc.impl;

import java.util.Collection;

import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.dao.doc.ShareUserDocDao;
import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.domain.doc.ShareUserDoc;
import com.prs.crm.domain.doc.UserDoc;

public class ShareUserDocDaoImpl extends BaseDaoImpl<ShareUserDoc> implements ShareUserDocDao{

	@Override
	public Collection<ShareUserDoc> getShareDoc(UserDoc userDoc) {
		// TODO Auto-generated method stub
		Criteria criteria = this.getSession().createCriteria(ShareUserDoc.class);
		criteria.add(Restrictions.eq("userDoc", userDoc));
		return criteria.list();
	}

	@Override
	public void deleteShareDoc(UserDoc userDoc) {
		// TODO Auto-generated method stub
		Query query = this.getSession().createQuery("delete from ShareUserDoc where userDoc=?");
		query.setParameter(0, userDoc);
		query.executeUpdate();
	}

}
